#ifndef __TIMER__H__
#define __TIMER__H__

#include <sys/time.h>

class Timer {
	public:
		void start() { gettimeofday( &t1, NULL ); }
		void stop() { gettimeofday( &t2, NULL ); }

		// En microsegundos.
		unsigned long long delta() {
			return
			 (static_cast<unsigned long long>(t2.tv_sec) - static_cast<unsigned long long>(t1.tv_sec)) * 1000000ULL +
			 	(static_cast<unsigned long long>(t2.tv_usec) - static_cast<unsigned long long>(t1.tv_usec));
		}
	private:
		struct timeval t1, t2;
};

#endif
